<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="t_quo" :rules="rules" label-width="100px" id="mvcfm">
          <div class="form-unit">
            <span class="mvc-title-left"> 增加生产计划 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="12">
                <el-form-item label="标题" prop="plan_title">
                  <el-input v-model="t_quo.plan_title" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="产品名称" prop="">
                  {{t_quo.product_name}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="产品数量" prop="product_num">
                  <el-input v-model="t_quo.sub_num" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="产品单位" prop="product_nuit">
                  <el-input v-model="t_quo.pronum_nuit" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="计划负责人" prop="">
                  {{t_quo.plan_charge}}
                  <el-button @click="popSelectionOfficerCurrency('','plan_charge')" type="success" size="mini"><i class="fa fa-edit"></i>选择</el-button>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="交货时间" prop="com_time">
                  <el-date-picker v-model="t_quo.pronum_endate" type="date" style='width:100%' value-format="yyyy-MM-dd" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="计划说明" prop="plan_explain">
                  <el-input type="textarea" v-model="t_quo.plan_explain" ttparea=350></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="备注" prop="remark">
                  <el-input type="textarea" v-model="t_quo.remark" ttparea=350></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-button @click="i_plan('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
          <el-button @click="gotoPage('/crm/sale/TransferManagement?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'销售合同'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
    <el-dialog :visible.sync="SelectionOfficerCurrencyVisible" append-to-body>
      <SelectionOfficerCurrency v-if="SelectionOfficerCurrencyVisible" ref="SelectionOfficerCurrency" :popparams="popparams"> </SelectionOfficerCurrency>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import SelectionOfficerCurrency from "@/views/crm/autooffice/SelectionOfficerCurrency";
  export default {
    name: 'ProductionPlan',
    components: {
      SelectionOfficerCurrency,
    },
    props: ['popparams'],
    data() {
      return {
        SelectionOfficerCurrencyVisible: false,
        SelectionOfficerCurrencyValue: null,
        SelectionOfficerCurrencyDesc: null,
        vueparams: this.getVUEParams(""),
        t_quo: {
          plan_title: null,
          product_name: null,
          sub_num: null,
          pronum_nuit: null,
          plan_charge: null,
          pronum_endate: null,
          plan_explain: null,
          remark: null,
        },
        loading: false,
        Container: null,
        rules: {
          plan_title: [{
            required: true,
            message: "标题不能为空",
            trigger: 'blur',
          }],
          product_num: [{
            required: true,
            message: "产品数量不能为空",
            trigger: 'blur',
          }],
          com_time: [{
            required: true,
            message: "交货时间不能为空",
            trigger: 'blur',
          }],
        }
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "80299289AF2443B18EA545A4C0C37170",
        name: "客户管理右菜单",
        selected: "销售合同"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/crm/sale/CustomerAction/productionPlan?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      i_plan(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/crm/sale/CustomerAction/i_plan?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/crm/sale/TransferManagement/transferManagement?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      popSelectionOfficerCurrency(desc, value) {
        this.SelectionOfficerCurrencyVisible = true;
        this.SelectionOfficerCurrencyDesc = desc;
        this.SelectionOfficerCurrencyValue = value;
      },
      closeSelectionOfficerCurrency(value, desc) {
        this.SelectionOfficerCurrencyVisible = false;
        this.$set(this.t_quo, this.SelectionOfficerCurrencyDesc, desc);
        this.$set(this.t_quo, this.SelectionOfficerCurrencyValue, value);
      },
    },
  }
</script>
